package com.itheima;

/**
 * 2025/3/21 20:25
 * 方法的演示，定义和调用
 */
public class MethodDemo {

    public static void main(String[] args) {
        double area1 = calculateArea(2);//alt+enter ，快速生成变量接收方法的返回值
        System.out.println("圆形的面积："+area1);
        double area2 = calculateArea(2, 3);
        System.out.println("长方形的面积："+area2);
        double area3 = calculateArea(2, 3, 4);
        System.out.println("梯形的面积："+area3);
    }

    //计算圆形的面积
    public static double calculateArea(double r) {
        return 3.14 * r * r;
    }
    //计算长方形的面积
    public static double calculateArea(double length, double width) {
        return length * width;
    }
    //计算梯形的面积
    public static double calculateArea(double base1, double base2, double height) {
        return (base1 + base2) * height / 2;
    }


}
